package com.onlineshop.highgee.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.onlineshop.highgee.dao.ShopCarDao;
import com.onlineshop.highgee.daoimpl.ShopCarDaoImpl;

/**
 * Servlet implementation class removeOneShopServlet
 */
/**
*椤圭洰鍚嶇О:HighGee
* 绫� 鍚� 绉�:RemoveOneShopServlet
* 绫� 鎻� 杩�:
* 鍒� 寤� 浜�:souk
*鍒涘缓鏃堕棿:2019骞�12鏈�25鏃ヤ笅鍗�1:20:59
*@version
 */
@WebServlet("/RemoveOneShopServlet")
public class RemoveOneShopServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		try {

			Object shopId = request.getParameter("delete");
			int id = Integer.parseInt((String) shopId);
			ShopCarDao shopCarDao = new ShopCarDaoImpl();
			shopCarDao.deleteOneCar(id);
			request.getRequestDispatcher("cart.jsp").forward(request, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
